package com.jrzh.mvc.search.sys;

import org.apache.commons.lang.StringUtils;

import com.jrzh.common.utils.DateUtil;
import com.jrzh.framework.base.search.BaseSearch;
import com.jrzh.framework.searchutils.Criteria;
import com.jrzh.framework.searchutils.Restrictions;

public class UserEventSearch extends BaseSearch{

	private static final long serialVersionUID = 4664269559492111819L;
	
	private String likeDescription;

	private String eqUserId;

	private String[] inUserId;
	
	private String likeUserName;
	
	private String geTime;
	
	private String leTime;

	public String getLikeDescription() {
		return likeDescription;
	}
	public void setLikeDescription(String likeDescription) {
		this.likeDescription = likeDescription;
	}

	public String getLikeUserName() {
		return likeUserName;
	}
	public void setLikeUserName(String likeUserName) {
		this.likeUserName = likeUserName;
	}
	@Override
	public void setCriterias(Criteria<?> criterias) {
		if(StringUtils.isNotBlank(likeUserName)){
			criterias.add(Restrictions.like("handlerName", "%"+likeUserName+"%"));
		}
		if(StringUtils.isNotBlank(likeDescription)){
			criterias.add(Restrictions.like("description", "%" + likeDescription + "%"));
		}
		if(StringUtils.isNotBlank(eqUserId)){
			criterias.add(Restrictions.eq("userId", eqUserId ));
		}
		if(null != inUserId && inUserId.length > 0){
			criterias.add(Restrictions.in("userId", inUserId));
		}
		if(StringUtils.isNotBlank(leTime)){
			criterias.add(Restrictions.lte("createTime", DateUtil.format(leTime + " 23:59:59")));
		}
		if(StringUtils.isNotBlank(geTime)){
			criterias.add(Restrictions.gte("createTime",  DateUtil.format(geTime + " 00:00:00")));
		}
	}

	public String[] getInUserId() {
		return inUserId;
	}

	public void setInUserId(String[] inUserId) {
		this.inUserId = inUserId;
	}

	public String getEqUserId() {
		return eqUserId;
	}

	public void setEqUserId(String eqUserId) {
		this.eqUserId = eqUserId;
	}
	public String getGeTime() {
		return geTime;
	}
	public void setGeTime(String geTime) {
		this.geTime = geTime;
	}
	public String getLeTime() {
		return leTime;
	}
	public void setLeTime(String leTime) {
		this.leTime = leTime;
	}
	
}
